package com.example.myapplication.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.example.myapplication.R;
import com.example.myapplication.utils.StatusBarUtils;


/**
 *
 * Created by Lx on 2018/9/27.
 */

public class AppbarLatoutDemo1 extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_appbardemo1);
       initView();
    }
    private void initView(){
        final Toolbar toolbar =  findViewById(R.id.appbar_layout_toolbar);
        StatusBarUtils.setTranslucentImageHeader(this,0,toolbar);
      //  toolbar.setTitleTextColor(Color.TRANSPARENT);
        toolbar.setTitle("这个标题不正经");
        toolbar.setTitleTextColor(getResources().getColor(R.color.white));
        setSupportActionBar(toolbar);

       // toolbar.inflateMenu(R.menu.menu_search);

        AppBarLayout appBarLayout = findViewById(R.id.appbar_layout);

        final CollapsingToolbarLayout collapsingToolbarLayout =  findViewById(R.id.collapse_layout);
        collapsingToolbarLayout.setTitle("");
        collapsingToolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.white));
        collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.white));
         //
       // collapsingToolbarLayout.setExpandedTitleColor(Color.TRANSPARENT);

//        appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
//            @Override
//            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
//
//                if(Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()){
//                    toolbar.setTitleTextColor(getResources().getColor(R.color.white));
//
//
//                }else{
//                    collapsingToolbarLayout.setTitle("");
//                }
//            }
//        });
    }
}
